#include "scene/wsyscene.h"
#include "geometry/wsymesh.h"

#include "geometry/wsycube.h"
#include "geometry/wsysphere.h"
#include "geometry/wsypath.h"

#include "geometry/wsysectionofpipe.h"

#include "scene/wsyperspectivecamera.h"


WSYScene::WSYScene() {
    this->camera = new WSYPerspectiveCamera();
    this->geometryObjects = new QList<QObject *>();
}

/** 物体示例1 */
void WSYScene::testInstance1() {
    qDebug() << "The place where the program starts.";
    //王诗阳测试用立方体
    WSYCube *myCube = new WSYCube(25, 25, 25);
    WSYMesh *cubeMesh = new WSYMesh();
    cubeMesh->object = myCube;
    cubeMesh->setPosition(-20, 0, 0);
    //cubeMesh->setRotationOfAngle(30, 0, 45);

    //王诗阳测试用球体
    WSYSphere *mySphere = new WSYSphere(15, 128, 64);

    WSYMesh *sphereMesh = new WSYMesh();

    sphereMesh->object = mySphere;
    sphereMesh->setPosition(20, 20, 0);


    //王诗阳测试用球体
    WSYSphere *mySphere2 = new WSYSphere(15, 128, 64);

    WSYMesh *sphereMesh2 = new WSYMesh();

    sphereMesh2->object = mySphere2;
    sphereMesh2->setPosition(20, -20, 0);

    //王诗阳测试用管道路径
    QList<Vertex3D *> *lines = new QList<Vertex3D *>();
    lines->append(new Vertex3D(0, 0, 0));
    lines->append(new Vertex3D(10, 0, 0));
    lines->append(new Vertex3D(9, 25, 4));
    WSYSectionOfPipe *pipe = new WSYSectionOfPipe(lines, 3, 8);
    pipe->generate();

    //将王诗阳测试用立方体和球体添加到物体数组中
    this->pushSingleObject(cubeMesh);
    this->pushSingleObject(sphereMesh);
    this->pushSingleObject(sphereMesh2);
}

/** 添加管线结构 */
void WSYScene::addPipeLine(QList<WSYPath *> *pipeLine) {
    qDebug() << "正在它十分危险的时候　";
    int pipeCount = pipeLine->count();
    for (int l = 0; l < pipeCount; l++) {
        WSYPath *line = pipeLine->at(l);
        WSYMesh *lineMesh = new WSYMesh();

        lineMesh->object = line;
        this->pushSingleObject(lineMesh);
    }
}
